extends Control

export(NodePath) var sms
export var shrink_degree=0
export var shrink_length=16
export var animation_time=0.2
export var pointer_patch=64
var origional_position=Vector2(0,0)

func _ready():
	origional_position=rect_global_position
	sms=get_node(sms)

func f():
#	sms.remove_all()
	sms.interpolate_property(
		self,
		"rect_global_position",
		rect_global_position,
		origional_position+Vector2(shrink_length,0),
#		rect_global_position.rotated(shrink_degree)+Vector2(shrink_length,0).rotated(shrink_degree),
		animation_time,Tween.TRANS_CUBIC,Tween.EASE_IN_OUT
	)
	sms.interpolate_property(
		sys.pointer,
		"rect_global_position",
		sys.pointer.rect_position,
#		rect_global_position-Vector2(pointer_patch,0).rotated(shrink_degree),
		rect_global_position-Vector2(pointer_patch,0),
		animation_time,Tween.TRANS_CUBIC,Tween.EASE_IN_OUT
	)
#	sms.interpolate_property(
#		sys.pointer,
#		"rect_rotation",
#		sys.pointer.rect_rotation,
#		rad2deg(shrink_degree),
#		animation_time,Tween.TRANS_CUBIC,Tween.EASE_IN_OUT
#	)
	sms.start()

func uf():
#	sms.remove_all()
	sms.interpolate_property(
		self,
		"rect_global_position",
		rect_global_position,
		origional_position,
		animation_time,Tween.TRANS_CUBIC,Tween.EASE_IN_OUT
	)
#	sms.interpolate_property(
#		sys.pointer,
#		"rect_global_position",
#		sys.pointer.rect_global_position,
##		origional_position-Vector2(2*shrink_length,0),
#		origional_position-Vector2(2*shrink_length,0).rotated(shrink_degree)-Vector2(pointer_patch,0).rotated(shrink_degree),
#		animation_time,Tween.TRANS_CUBIC,Tween.EASE_IN_OUT
#	)
#	sms.interpolate_property(
#		sys.pointer,
#		"rect_rotation",
#		sys.pointer.rect_rotation,
#		rad2deg(shrink_degree),
#		animation_time,Tween.TRANS_CUBIC,Tween.EASE_IN_OUT
#	)
	sms.start()

func _notification(what):
	match what:
		NOTIFICATION_MOUSE_ENTER:
			f()
		NOTIFICATION_MOUSE_EXIT:
			uf()
		NOTIFICATION_FOCUS_ENTER:
			f()
		NOTIFICATION_FOCUS_EXIT:
			uf()
